<?php
/**
 * XGPHP 轻量级PHP框架
 * @link http://xgphp.xg3.cn
 * @version 2.0.0
 * @license http://www.apache.org/licenses/LICENSE-2.0
 * @author 讯高科技 <xungaokeji@qq.com>
*/
namespace xg\response;
use \helper\File as FileHelper;

class File extends \xg\Response {
	protected $filePath = null;
	
	public function setFile(string $file) {
		$this->filePath = $file;
		return $this;
	}
	
	protected function output() {
		if (is_file($this->filePath)) {
			$ext = strtolower(FileHelper::ext($this->filePath));
			$cont = FileHelper::cont($this->filePath);
			$this->mime($ext)->content($cont);
		}
		return $cont;
	}
}
?>